<?php
/**
* Module change logs
* 09/29/2010        immanuel192         First create, based on Linklist module
* 
* 
*/

if (!defined('EXPONENT')) exit('');

$link = null;
if (isset($_POST['id'])) {
    $_POST['id']=intval($_POST['id']);
	$link = $db->selectObject('imageslider_image','id='.$_POST['id']);
	if ($link) {
		$loc = unserialize($link->location_data);
	}
} else {
	$link->rank = $db->max('imageslider_image', 'rank', 'location_data', "location_data='".serialize($loc)."'");
	if ($link->rank == null) {
		$link->rank = 0;
	} else {
		$link->rank += 1;
	}
}

// permission check
if ( exponent_permissions_check('administrate',$loc) || 
     exponent_permissions_check('configure',$loc)) {          
	$link = imageslider_image::update($_POST,$link);
	$link->location_data = serialize($loc);

	if (isset($link->id)) {
		$db->updateObject($link,'imageslider_image');
	} else {
		$db->insertObject($link,'imageslider_image');
	}
	exponent_flow_redirect();
} else {
	echo SITE_404_HTML;
}

?>